package com.zl.classroommanagement.service.impl;

import java.util.Date;
import java.util.List;
import com.zl.common.utils.DateUtils;
import com.zl.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zl.classroommanagement.mapper.QrcdeUserMapper;
import com.zl.classroommanagement.domain.QrcdeUser;
import com.zl.classroommanagement.service.IQrcdeUserService;

/**
 * 二维码用户Service业务层处理
 *
 * @author zl
 * @date 2022-05-03
 */
@Service
public class QrcdeUserServiceImpl implements IQrcdeUserService
{
    @Autowired
    private QrcdeUserMapper qrcdeUserMapper;

    /**
     * 查询二维码用户
     *
     * @param id 二维码用户主键
     * @return 二维码用户
     */
    @Override
    public QrcdeUser selectQrcdeUserById(Long id)
    {
        return qrcdeUserMapper.selectQrcdeUserById(id);
    }

    /**
     * 查询二维码用户列表
     *
     * @param qrcdeUser 二维码用户
     * @return 二维码用户
     */
    @Override
    public List<QrcdeUser> selectQrcdeUserList(QrcdeUser qrcdeUser)
    {
        return qrcdeUserMapper.selectQrcdeUserList(qrcdeUser);
    }

    /**
     * 新增二维码用户
     *
     * @param qrcdeUser 二维码用户
     * @return 结果
     */
    @Override
    public int insertQrcdeUser(QrcdeUser qrcdeUser)
    {
        qrcdeUser.setCreateTime(DateUtils.getNowDate());
        return qrcdeUserMapper.insertQrcdeUser(qrcdeUser);
    }

    /**
     * 修改二维码用户
     *
     * @param qrcdeUser 二维码用户
     * @return 结果
     */
    @Override
    public int updateQrcdeUser(QrcdeUser qrcdeUser)
    {
        qrcdeUser.setUpdateTime(DateUtils.getNowDate());
        return qrcdeUserMapper.updateQrcdeUser(qrcdeUser);
    }

    /**
     * 批量删除二维码用户
     *
     * @param ids 需要删除的二维码用户主键
     * @return 结果
     */
    @Override
    public int deleteQrcdeUserByIds(Long[] ids)
    {
        return qrcdeUserMapper.deleteQrcdeUserByIds(ids);
    }

    /**
     * 删除二维码用户信息
     *
     * @param id 二维码用户主键
     * @return 结果
     */
    @Override
    public int deleteQrcdeUserById(Long id)
    {
        return qrcdeUserMapper.deleteQrcdeUserById(id);
    }

    /**
     * 根据二维码信息修改用户状态
     *
     * @param teachercard
     * @param userName
     * @return
     */
    @Override
    public int qrcodeuserByStatus(Long teachercard, String userName) {
        QrcdeUser qrcdeUser = new QrcdeUser();
        qrcdeUser.setUpdateBy(SecurityUtils.getUsername());
        qrcdeUser.setUpdateTime(new Date());
        qrcdeUser.setTeachercard(teachercard);
        qrcdeUser.setUserAme(userName);
        qrcdeUser.setStatus("1");
        return qrcdeUserMapper.qrcodeuserByStatus(qrcdeUser);
    }
}
